
setwd("/Users/michelemargolis/Dropbox/MIT/Spring 2011/Gov 2001/Replication Paper/Our Replication/")

########### LOAD LIBRARIES ############

library(Zelig)
library(foreign)
library(rgernoud)
library(Matching)
library(lattice)
library(Amelia)
library(sandwich)
library(Hmisc)
library(Design)

########### SET UP ############

treaty1 <- read.dta("Treaty_mi_1.dta")
treaty2 <- read.dta("Treaty_mi_2.dta")
treaty3 <- read.dta("Treaty_mi_3.dta")
treaty4 <- read.dta("Treaty_mi_4.dta")
treaty5 <- read.dta("Treaty_mi_5.dta")



###TO GET COEFFICIENTS##
replicate3 <- zelig(restrict ~ art8 + shift_left + flexible + gnpcap + regnorm + gdpgrow + resgdp + bopgdp + useimfcr + surveil + univers + resvol + totvol + tradedep + military + termlim + parli + lastrest + lastrest2 + lastrest3, model = "logit", data = mi(treaty1, treaty2, treaty3, treaty4, treaty5))
summary(replicate3)


##TO GET STANDARD ERRORS##
fml <- as.formula(restrict ~ art8 + shift_left +
flexible + gnpcap + regnorm + gdpgrow +
resgdp + bopgdp + useimfcr + surveil +
univers + resvol + totvol + tradedep +
military + termlim + parli + lastrest + lastrest2 + lastrest3)

tempcls<-lrm(fml, x=TRUE, y=TRUE, data=treaty1)
g1 <- robcov(tempcls, treaty1[,1])

####DATASET #2######

tempcls<-lrm(fml, x=TRUE, y=TRUE, data=treaty2)
g2 <- robcov(tempcls, treaty2[,1])

####DATASET #3######

tempcls<-lrm(fml, x=TRUE, y=TRUE, data=treaty3)
g3 <- robcov(tempcls, treaty3[,1])

####DATASET #4######

tempcls<-lrm(fml, x=TRUE, y=TRUE, data=treaty4)
g4 <- robcov(tempcls, treaty4[,1])


####DATASET #5####

tempcls<-lrm(fml, x=TRUE, y=TRUE, data=treaty5)
g5 <- robcov(tempcls, treaty5[,1])



ses1<-sqrt(diag(g1$var))
ses2<-sqrt(diag(g2$var))
ses3<-sqrt(diag(g3$var))
ses4<-sqrt(diag(g4$var))
ses5<-sqrt(diag(g5$var))

avses<-(ses1+ses2+ses3+ses4+ses5)/5

avses


